#ifndef GLOBAL_EVENT_DEFINE_H
#define GLOBAL_EVENT_DEFINE_H
#define MAX_PLAYER_NAME 128
#define MAX_GO_INSTANCE	512

#define WM_EVENT_WRAPPER_FOR_THREAD_SAFE WM_USER+100

enum{
	GAME_TYPE_WEIQI,
};
typedef unsigned int GAME_TYPE_T;
enum{
	STATUS_INVALID=0,
	PLAYER_IDLE,
	PLAYER_WAIT_FOR_JOIN,
	PLAYER_IN_GAME,

	INSTANCE_IDLE,
	INSTANCE_WAIT_FOR_JOIN,
	INSTANCE_IN_GAME,
};
typedef unsigned int STATUS_TYPE_T;
enum{
	EVENT_INVALID=0,
	EVENT_START,
	SYS_EVENT_ACTIVE_DISPATCH,

	WIDGET_EVENT_START,
	WIDGET_EVENT_ANIMATE_FRAME_FINISH,
	WIDGET_EVENT_ANIMATE_THREAD_FINISH,
	WIDGET_EVENT_CONTENT_UPDATED,
	WIDGET_EVENT_POSITION_CHANGED,


	WIDGET_LIST_ITEM_SELECTED,
	WIDGET_EVENT_END,

	WEIQI_EVENT_START,
	WEIQI_EVENT_UI_MOVE_CHESS,
	WEIQI_EVENT_UI_MOVE_CHESS_RSP,
	WEIQI_EVENT_SOCKET_MOVE_CHESS,
	WEIQI_EVENT_CREATE_GAME,
	WEIQI_EVENT_CREATE_GAME_RSP,
	WEIQI_EVENT_JOIN_GAME,
	WEIQI_EVENT_JOIN_GAME_RSP,
	WEIQI_EVENT_LIST_GAME,
	WEIQI_EVENT_LIST_GAME_RSP,
	WEIQI_EVENT_INFO_GAME,
	WEIQI_EVENT_INFO_GAME_RSP,	
	WEIQI_EVENT_EXIT_GAME,
	WEIQI_EVENT_EXIT_GAME_RSP,
	WEIQI_EVENT_PLAYER_DISCONNECT,
	WEIQI_EVENT_PLAYER_EXIT,
	WEIQI_EVENT_GAME_UPDATED,
	WEIQI_EVENT_LAUNCH_GO_VIEW,	
	WEIQI_EVENT_JOIN_GAME_REQUEST,
	WEIQI_EVENT_ACCEPT_JOIN,
	WEIQI_EVENT_START_GAME,
	WEIQI_EVENT_PLAYER_PASS,
	WEIQI_EVENT_UI_PLAYER_PASS,
	WEIQI_EVENT_DRAGON_DEAD,
	WEIQI_EVENT_NEXT_TURN,
	WEIQI_EVENT_START_DIANMU,
	WEIQI_EVENT_DIANMU_RESULT,
	WEIQI_EVENT_REQ_DIANMU,
	WEIQI_EVENT_HELLO,
	WEIQI_EVNET_CONNECT_STATUS,

	WEIQI_EVENT_SEND_SOCKET_EVENT,
	WEIQI_EVENT_END,
	EVENT_END,
};
typedef unsigned int EVENT_TYPE_T;
typedef struct{
	STATUS_TYPE_T status;
	EVENT_TYPE_T evt;

}EVENT_STATUS_MAP_T;

enum{
	WEIQI_SIDE_NULL,
	WEIQI_SIDE_WHITE,
	WEIQI_SIDE_BLACK,
};
#define ANOTHER_SIDE(SIDE) \
	(((SIDE)==WEIQI_SIDE_BLACK)?WEIQI_SIDE_WHITE:WEIQI_SIDE_BLACK)
#define FREE_SIDE(PLAYER_ID) \
	(((PLAYER_ID)==0)?WEIQI_SIDE_BLACK:WEIQI_SIDE_WHITE)

typedef unsigned int WEIQI_SIDE_T;



typedef struct{
	unsigned int instance_id;
	unsigned int black_player_id;
	unsigned int white_player_id;
	unsigned int wait;
	unsigned int status;
}GO_INSTANCE_STATE_T;



typedef struct{
	unsigned int palyer_id;
	char name[MAX_PLAYER_NAME];
	unsigned int num_win;
	unsigned int num_lost;
	unsigned int score;	
	unsigned int status;
}GO_PLAYER_STATE_T;


typedef
struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int chess_side;
	 unsigned int x;
	 unsigned int y;
	 unsigned int player_id;
	 unsigned int instance_id;
	 unsigned char bOK;
}EVENT_MOVE_CHESS_T;

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int game_size;
	 unsigned int chess_side;	 
	 unsigned char name[MAX_PLAYER_NAME];
}EVENT_CREATE_GAME_T;

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
	 unsigned int player_id;
}EVENT_EXIT_GAME_T;
typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
	 unsigned int player_id;
}EVENT_EXIT_GAME_RSP_T;
typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int game_size;
	 unsigned int chess_side;	 
	 unsigned int player_id;
	 unsigned int instance_id;
	 unsigned int game_type;

}EVENT_CREATE_GAME_RSP_T;

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int src_chess_side;	 
	 unsigned int target_chess_side;
	 unsigned char src_name[MAX_PLAYER_NAME];
	 unsigned int instance_id;
	 unsigned int src_player_id;
	 unsigned int target_player_id;
}EVENT_JOIN_GAME_T;

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int src_chess_side;	 
	 unsigned int target_chess_side;
	 unsigned char src_name[MAX_PLAYER_NAME];
	 unsigned char target_name[MAX_PLAYER_NAME];
	 unsigned int instance_id;
	 unsigned int game_size;
	 unsigned int src_player_id;
	 unsigned int target_player_id;
	 unsigned char bAccept;
}EVENT_JOIN_GAME_RSP_T;


typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned char name[MAX_PLAYER_NAME];
}EVENT_LIST_GAME_T;

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
}EVENT_INFO_GAME_T;

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
	 unsigned char bNoExist;
	GO_INSTANCE_STATE_T instance_state;
	GO_PLAYER_STATE_T blacker;
	GO_PLAYER_STATE_T whiter;
	

}EVENT_INFO_GAME_RSP_T;

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
	  unsigned char bNoExist;
	GO_INSTANCE_STATE_T* instance_state;
	GO_PLAYER_STATE_T* blacker;
	GO_PLAYER_STATE_T* whiter;
}LOCAL_EVENT_INFO_GAME_RSP_T;
//Dynamic msg

typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int num_of_instance;	 
}EVENT_LIST_GAME_RSP_T;




typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
	 unsigned int player_id;
}EVENT_PLAYER_DISCONNECT_T;
typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
	 unsigned int player_id;
}EVENT_PLAYER_EXIT_T;


typedef struct{
	 EVENT_TYPE_T ev_type;
	 unsigned int instance_id;
}EVENT_GAME_UPDATED_T;


typedef struct{
	EVENT_TYPE_T ev_type;
	unsigned int you_player_id;
	unsigned int other_player_id;
	unsigned int instance_id;
	unsigned int you_side;
	unsigned int game_size;
}EVENT_LAUNCH_GO_VIEW_T;

typedef struct{
	EVENT_TYPE_T ev_type;	
	unsigned int you_player_id;
	unsigned int other_player_id;
	unsigned int instance_id;
	unsigned int you_side;
	unsigned int game_size;
}EVENT_START_GAME_T;


typedef struct{
	EVENT_TYPE_T ev_type;
	unsigned int m_pEventDispatcher;
}EVENT_SYS_ACTIVE_DISPATCH_T;

typedef struct{
	unsigned int player_id;
	int evt_type;
	int	 data;
	int data_len;
}EVENT_SEND_SOCKET_EVENT_T;

typedef struct{
	EVENT_TYPE_T et_type;
	unsigned int player_id;
	unsigned int side;
	unsigned int instance_id;
}EVENT_COMMON_HEADER_T;

typedef struct{
	EVENT_COMMON_HEADER_T common;
}EVENT_PLAYER_PASS_T;

typedef struct{
	EVENT_TYPE_T et_type;
	unsigned int side;
	unsigned int dragon[24];
}EVENT_DRAGON_DEAD_T;
typedef struct{
	EVENT_TYPE_T et_type;
	unsigned int next_side;	
}EVENT_NEXT_TURN_T;
typedef struct{
	EVENT_TYPE_T et_type;
	unsigned int src_side;	
}EVENT_START_DIANMU_T;
typedef struct{
	EVENT_TYPE_T et_type;
	unsigned int instance_id;
	unsigned int src_side;	
}EVENT_REQ_DIANMU_T;
typedef struct{
	EVENT_TYPE_T et_type;	
	unsigned int instance_id;
	unsigned int black_mu[24];
	unsigned int white_mu[24];
}EVENT_DIANMU_RESULT_T;
typedef struct{
	EVENT_TYPE_T et_type;	
	 unsigned char name[MAX_PLAYER_NAME];
}EVENT_HELLO_T;

typedef struct{
	unsigned int error_code;
}EVENT_CONNECT_STATUS_T;




typedef struct {
	void* pContorller;
	void* pAnimateParam;
}EVENT_ANIMATE_FRAME_FINISH_T;

typedef struct {
	void* pThread;
}EVENT_ANIMATE_THREAD_FINISH_T;

#endif